package org.windblog.core.servlet.comment;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.windblog.core.CommentService;
import org.windblog.core.entity.Comment;



@SuppressWarnings("serial")
public class DeleteCommentServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		String commentKey = request.getParameter("comment").trim();
		String curview = request.getParameter("curview");
		if(commentKey!=null )
		{
			Comment comment = CommentService.getComment(commentKey);
			if(comment!=null)
			{
				CommentService.deleteComment(comment);
			}
		}
		if(curview==null||curview.trim().length()==0)
			response.sendRedirect("/admin/editComments.jsp");
		else
			response.sendRedirect("/admin/editComments.jsp?comment_status="+curview);

	}
	
}